<?php
session_start();
$index = 1;

require_once("config/settings.php");
require_once('config/database.php');

function __autoload($class) {
    require_once("classes/$class.class.php");
}

if(kick_db_users && !allow_db_users && $_SESSION['login'] != admin_username && $_SESSION['login'])
{
    session_destroy();
    echo("<meta http-equiv='refresh' content='0;url=index.php?p=main'>");
}

class Main {
    public static function get_page() {
        if(isset($_GET['p']))
            $page = $_GET['p'];
        else
            $page = "/";
        if(!(strpos($page, "/")) && !(strpos($page, ".")) && $page)
        {
            $path = "pages/$page.php";
            if(file_exists($path))
            {
                return $path;
            }
            else if ($page == "/")
            {
                return "pages/home.php";
            }
            else
            {
                return("pages/404.php");
            }
        }
    }
}
?>